package cn.funeralobjects.dictms.web.mapper;

import cn.funeralobjects.dictms.entity.EDictRelatePath;
import cn.funeralobjects.dictms.web.model.VDictRelatePath;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author FuneralObjects
 * Create date: 2020/6/10 6:27 AM
 */
@Mapper(componentModel = "spring")
public interface DictValuePathMapper {

    @Mappings({
            @Mapping(target = "headValueId", source = "headValue.id"),
            @Mapping(target = "relateId", source = "relate.id"),
            @Mapping(target = "dictValueId", source = "dictValue.id")
    })
    VDictRelatePath toVo(EDictRelatePath entity);

    default List<VDictRelatePath> toVo(List<EDictRelatePath> entities) {
        return entities == null ? null : entities.stream().map(this::toVo).collect(Collectors.toList());
    }
}
